package com.app.micaihu.view.comment;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.android.volley.VolleyError;
import com.app.micaihu.R;
import com.app.micaihu.app.AppApplication;
import com.app.micaihu.base.BaseListActivity;
import com.app.micaihu.base.bean.DataBean;
import com.app.micaihu.bean.comment.CommentSecondaryBean;
import com.app.micaihu.bean.comment.NormalComment;
import com.app.micaihu.bean.comment.PariseBean;
import com.app.micaihu.bean.infor.UserInfor;
import com.app.micaihu.bean.news.NewsEntity;
import com.app.micaihu.bean.speak.ICommentEntity;
import com.app.micaihu.bean.speak.ILaud;
import com.app.micaihu.bean.topic.PostCmtSecondaryBean;
import com.app.micaihu.bean.topic.PostCmtSecondaryHeaderBean;
import com.app.micaihu.configure.Config;
import com.app.micaihu.configure.TypeConstant;
import com.app.micaihu.configure.URIContant;
import com.app.micaihu.custom.view.CircleImageOnly;
import com.app.micaihu.custom.view.CustomImageView;
import com.app.micaihu.listener.HttpListener;
import com.app.micaihu.listener.LaudListener;
import com.app.micaihu.manager.UserInforManager;
import com.app.micaihu.utils.CommentUtils1;
import com.app.micaihu.utils.ImageLoadUtils;
import com.app.micaihu.utils.InteractiveUtils;
import com.app.micaihu.view.comment.adapter.SecondaryCommentAdapter;
import com.app.micaihu.view.newsdetail.CommentPariseActivity;
import com.app.micaihu.view.user.userinfo.activity.MyHomepageDynamicActivity;
import com.app.utils.pulltorefresh.PullToRefreshBase;
import com.app.utils.util.ViewSizeUtils;
import com.app.utils.util.image.LoadImageUtils;
import com.app.utils.util.view.expression.view.BiaoQinTextView;
import com.blankj.utilcode.util.ActivityUtils;
import com.google.gson.reflect.TypeToken;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * Created by Guo on 2016/7/31.
 * <p>
 * 次级评论详情
 */
public class SecondaryCommentDetailActivity extends BaseListActivity<NormalComment> {

    private String newsId;
    private SubmitCommentListener commentListener;
    private TextView mUsername;
    private CustomImageView mUserRank;
    private TextView mComZan;
    private TextView mComTime;
    private BiaoQinTextView mComMesg;
    private CustomImageView mNewsImg;
    //    private TextView mNewsTitle;
    private BiaoQinTextView mNewsTitle;
    private TextView mUserRankText;
    private TextView tvArmyGroupInfo;
    private String commentId;
    private CommentSecondaryBean commentSecondaryBean;
    private CustomImageView mUserImg;
    private ImageView ivHonourPic;
    private View pariseLayoutContainer;
    private LinearLayout pariseListView;//点赞头像 的父控件
    private TextView pariseSum;
    private View pariseBotLine;


    private String newsTypeName;//当前评论的 title 名字

    public static final String COMMENT_OR_POST = "comment_or_post";//评论还是帖子的二级评论
    private boolean isComment;//当前页面是评论还是帖子的二级评论
    private PostCmtSecondaryHeaderBean postCmtSecondaryHeaderBean;
    private List<PariseBean> praiseList;
    private ICommentEntity iCommentEntity;
    private boolean lauded;//是否点赞
    private FrameLayout laud;


    @Override
    public void onCreate(Bundle savedInstanceState) {
        Intent intent = getIntent();
        if (intent != null) {
            newsId = intent.getStringExtra(Config.Extra.PARAMETER1);
            commentId = intent.getStringExtra(Config.Extra.PARAMETER2);
            isComment = intent.getBooleanExtra(COMMENT_OR_POST, true);
            if (TextUtils.isEmpty(newsId)) {
                return;
            }
        }
        super.onCreate(savedInstanceState);

    }

    @Override
    protected void changeView() {
        setTitle(getResources().getString(R.string.detail_image_comment_title));

        View headView = LayoutInflater.from(this).inflate(R.layout.layout_comment_detail_head, null);

        mUserImg = (CustomImageView) headView.findViewById(R.id.comment_usericon);
        ivHonourPic = headView.findViewById(R.id.ivHonourPic);
        tvArmyGroupInfo = headView.findViewById(R.id.tvArmyGroupInfo);
        mUsername = (TextView) headView.findViewById(R.id.comment_username);
        mUserRank = (CustomImageView) headView.findViewById(R.id.comment_rank);
        mComZan = (TextView) headView.findViewById(R.id.comment_zan);
        laud = (FrameLayout) headView.findViewById(R.id.fl_laud_container);
        mComTime = (TextView) headView.findViewById(R.id.comment_time);
        mComMesg = (BiaoQinTextView) headView.findViewById(R.id.comment_message);
        mNewsImg = (CustomImageView) headView.findViewById(R.id.comment_news_img);
        mNewsTitle = (BiaoQinTextView) headView.findViewById(R.id.comment_news_title);
        mUserRankText = (TextView) headView.findViewById(R.id.comment_rank_name);
        View titleLayout = headView.findViewById(R.id.comment_news_layout);
        RelativeLayout container = (RelativeLayout) headView.findViewById(R.id.rl_container);
        container.setOnClickListener(this);


        titleLayout.setOnClickListener(this);
        mComMesg.setOnClickListener(this);
        mUserImg.setOnClickListener(this);
        mUsername.setOnClickListener(this);
        laud.setOnClickListener(this);


        //点赞列表
        pariseLayoutContainer = headView.findViewById(R.id.comment_parise_layout);
        pariseLayoutContainer.setOnClickListener(this);
        pariseListView = (LinearLayout) headView.findViewById(R.id.comment_zan_list);
        pariseSum = (TextView) headView.findViewById(R.id.comment_zan_sum);
        pariseBotLine = headView.findViewById(R.id.commont_zan_driver);

        //添加头部view
        mListView.getRefreshableView().addHeaderView(headView);

        if (flCommonBottom != null) {
            View view = this.getLayoutInflater().inflate(R.layout.layout_imagecomment_bottom, null);
            flCommonBottom.addView(view);
            flCommonBottom.setOnClickListener(this);
        }
    }

    /**
     * 直接回复当前的header
     */
    private void showCommentDialog() {
        if (commentListener == null) {
            commentListener = new SubmitCommentListener() {
                @Override
                public void startSubmit() {
                }

                @Override
                public void errorSubmit(VolleyError error) {
                }

                @Override
                public void successSubmit(NormalComment normalComment) {
                    //更新页面
                    if (normalComment == null) {
                        return;
                    }
                    if (dataList == null) {
                        dataList = new ArrayList<NormalComment>();
                    }
                    if (dataList.size() == 0) {
                        NormalComment comment = new NormalComment();
                        comment.setCommentTitle(AppApplication.getInstance().getString(R.string.speak_title_all));
                        dataList.add(0, comment);
                    }

                    if (dataList.size() == 1 && dataList.get(0) == null) {
                        //在第一个位置添加最新评论
                        dataList.clear();
                        NormalComment comment = new NormalComment();
                        comment.setCommentTitle(AppApplication.getInstance().getString(R.string.speak_title_all));
                        dataList.add(0, comment);
                    }

                    if (!isComment) {
                        normalComment.setType(TypeConstant.COMMENT_ONE);
                    }
                    dataList.add(1, normalComment);
                    if (mAdapter == null) {
                        mAdapter = new SecondaryCommentAdapter(dataList, mActivity);
                        mListView.setAdapter(mAdapter);
                    } else {
                        mAdapter.notifyDataSetChanged();
                    }
                }
            };
        }


        if (isComment) {
            CommentUtils1.getInstance().showDialog(mActivity, mPageName, newsId, commentSecondaryBean, commentListener, isComment, false);
        } else {
            CommentUtils1.getInstance().showDialogInSecondaryPost(mActivity, mPageName, newsId, postCmtSecondaryHeaderBean, commentListener, isComment, true);
        }


    }


    @Override
    protected void changeData(final boolean isRefresh) {
        Map<String, String> params = new HashMap<>();
        if (isComment) {
            params.put("articleId", newsId);
        } else {
            params.put("topicId", newsId);

        }
        params.put("page", dataPage + "");
        params.put("commentId", commentId);
        if (UserInforManager.getInstance().isLogin()) {
            params.put("uid", UserInforManager.getInstance().getUserInfor().getUid());
        }

        if (isComment) {
            requestCommentData(isRefresh, params);
        } else {
            requestPostData(isRefresh, params);
        }

    }


    /**
     * 当前页面是帖子的时候
     *
     * @param isRefresh
     * @param params
     */
    private void requestPostData(final boolean isRefresh, Map<String, String> params) {

        HttpListener<DataBean<PostCmtSecondaryBean>> commentListener = new HttpListener<DataBean<PostCmtSecondaryBean>>() {

            @Override
            public void onStart() {
                super.onStart();
                setLoadView(LOADING, null);
            }

            @Override
            public void onError(VolleyError error) {
                setLoadView(NO_NET, AppApplication.getInstance().getString(R.string.neterror_click));
            }

            @Override
            public void onSuccess(DataBean<PostCmtSecondaryBean> response) {
                if (!response.noError()) {
                    setLoadView(DATAERROR, response.getMsg());
                } else {
                    PostCmtSecondaryBean postCmtSecondaryBean = response.getData();
                    if (postCmtSecondaryBean != null) {
                        postCmtSecondaryHeaderBean = response.getData().getCmtInfo();

                        if (postCmtSecondaryHeaderBean != null) {
                            newsTypeName = TypeConstant.getNewsTypeName(postCmtSecondaryBean.getCmtInfo().getArticleType());
                            if (isRefresh) {
                                iCommentEntity = response.getData().getCmtInfo();
                                setHeaderData(newsTypeName);

                            }
                            bindListData(isRefresh, postCmtSecondaryBean.getChildList());
                        }


                    } else {
                        setLoadView(NO_NET, AppApplication.getInstance().getString(R.string.neterror_click));
                    }

                }
            }
        };


        addPostCacheRequest(URIContant.TOPIC_POST_COMMENT_DETAIL_2052, new TypeToken<DataBean<PostCmtSecondaryBean>>() {
        }.getType(), params, commentListener);


    }


    /**
     * 当前页面是评论的时候
     *
     * @param isRefresh
     * @param params
     */
    private void requestCommentData(final boolean isRefresh, Map<String, String> params) {
        HttpListener<DataBean<CommentSecondaryBean>> commentListener = new HttpListener<DataBean<CommentSecondaryBean>>() {
            @Override
            public void onStart() {
                super.onStart();
                setLoadView(LOADING, null);
            }

            @Override
            public void onError(VolleyError error) {
                setLoadView(NO_NET, AppApplication.getInstance().getString(R.string.neterror_click));
            }

            @Override
            public void onSuccess(DataBean<CommentSecondaryBean> response) {
                if (!response.noError()) {
                    setLoadView(DATAERROR, response.getMsg());
                } else {
                    commentSecondaryBean = response.getData();
//                    mComZan.setTag(commentSecondaryBean);

                    if (commentSecondaryBean != null) {
                        newsTypeName = TypeConstant.getNewsTypeName(commentSecondaryBean.getArticleType());
                        if (isRefresh) {
                            setHeaderData(newsTypeName);
                            iCommentEntity = response.getData();
                        }

                        bindListData(isRefresh, commentSecondaryBean.getChildList());
                    } else {
                        setLoadView(NO_NET, AppApplication.getInstance().getString(R.string.neterror_click));
                    }
                }
            }
        };
        addPostCacheRequest(URIContant.NEWSCOMMENTDETAIL, new TypeToken<DataBean<CommentSecondaryBean>>() {
        }.getType(), params, commentListener);
    }


    /**
     * 绑定 listview 数据
     *
     * @param isRefresh
     * @param list
     */
    private void bindListData(boolean isRefresh, List<NormalComment> list) {
        if (dataList == null) {
            dataList = new ArrayList<NormalComment>();
        }
        if (list != null && list.size() > 0) {

            for (int i = 0; i < list.size(); i++) {
                if (InteractiveUtils.getInstance().theDefriendIsContains(list.get(i).getUid())) {
                    list.remove(list.get(i));
                    i--;
                }
            }

            //数据去重
            if (isRefresh) {
                dataList.clear();
                //在第一个位置添加最新评论
                if (list.size() > 0) {
                    NormalComment comment = new NormalComment();
                    comment.setCommentTitle(AppApplication.getInstance().getString(R.string.speak_title_all));
                    dataList.add(0, comment);
                }

            }
            //追加数据集合
            dataList.addAll(list);
        }
        if (mAdapter == null) {
            if (dataList.size() == 0) {
                dataList.add(null);
                flCommonBottom.performClick();
            }
            mAdapter = new SecondaryCommentAdapter(dataList, mActivity);
            mListView.setAdapter(mAdapter);
        } else {
            mAdapter.notifyDataSetChanged();
        }
        setLoadView(LOADSUCES, null);
    }


    @Override
    public void onClick(View view) {
        super.onClick(view);
        if (view == null) {
            return;
        }
        switch (view.getId()) {
            case R.id.fl_laud_container://点赞
                InteractiveUtils.getInstance().laud((FrameLayout) view, laudListener);
                break;

            case R.id.comment_news_layout://点击新闻
                toNewsDetail();
                break;
            case R.id.comment_username://点击头像
            case R.id.comment_usericon://点击昵称
                if (iCommentEntity != null) {
//                    gonToUserHome(commentSecondaryBean.getIToUid());
                    MyHomepageDynamicActivity.goToUserHomePage(this, iCommentEntity.getIToUid());
                }
                break;
            case R.id.comment_message://点击回复内容
            case R.id.fl_common_bottom://点击底部评论框
            case R.id.rl_container://点击底部评论框
                showCommentDialog();
                break;
            case R.id.comment_parise_layout://跳转点赞列表
                if (!TextUtils.isEmpty(newsId) && !TextUtils.isEmpty(commentId)) {
                    Intent intent1 = new Intent(this, CommentPariseActivity.class);
                    intent1.putExtra(Config.Extra.PARAMETER1, newsId);
                    intent1.putExtra(Config.Extra.PARAMETER2, commentId);
                    startActivity(intent1);
                }
                break;
        }
    }

    /**
     * 设置头部信息
     *
     * @param newsTypeName
     */
    private void setHeaderData(String newsTypeName) {
        if (isComment && commentSecondaryBean != null) {
            initICommentData(commentSecondaryBean);
            mNewsTitle.setMaxLines(2);
            ViewGroup.LayoutParams layoutParams = mNewsTitle.getLayoutParams();
            if (layoutParams != null) {
                layoutParams.height = ViewSizeUtils.dp2px(this, 50);
            }
            mNewsTitle.setLayoutParams(layoutParams);


            mNewsTitle.setText(AppApplication.getInstance().getString(R.string.m_bracket, newsTypeName, commentSecondaryBean.getArticleTitle()));
            if (commentSecondaryBean.getArticleThumb() != null && commentSecondaryBean.getArticleThumb().size() > 0) {
                LoadImageUtils.getInstance().loadImage(mNewsImg, commentSecondaryBean.getArticleThumb().get(0));
            }
            //拿取点赞列表
            initPariseView(commentSecondaryBean, commentSecondaryBean.getPraiseList());
        } else if (!isComment && postCmtSecondaryHeaderBean != null) {

            initICommentData(postCmtSecondaryHeaderBean);
            mNewsTitle.setText(AppApplication.getInstance().getString(R.string.m_bracket, newsTypeName, postCmtSecondaryHeaderBean.getTitle()));
            if (!TextUtils.isEmpty(postCmtSecondaryHeaderBean.getThumb())) {
                LoadImageUtils.getInstance().loadImage(mNewsImg, postCmtSecondaryHeaderBean.getThumb());
                mNewsImg.setVisibility(View.VISIBLE);
            }


            mComMesg.setVisibility(View.GONE);
//                mNewsTitle.setPicText(AppApplication.getInstance().getString(R.string.m_bracket, newsTypeName, postCmtSecondaryHeaderBean.getContent()));
            mNewsTitle.setMaxLines(Integer.MAX_VALUE);
            ViewGroup.LayoutParams layoutParams = mNewsTitle.getLayoutParams();
            if (layoutParams != null) {
                layoutParams.height = ViewGroup.LayoutParams.WRAP_CONTENT;
            }
            mNewsTitle.setLayoutParams(layoutParams);

            mNewsTitle.setPicText(postCmtSecondaryHeaderBean.getContent());
            mNewsImg.setVisibility(View.GONE);


            //拿取点赞列表
            initPariseView(postCmtSecondaryHeaderBean, postCmtSecondaryHeaderBean.getPraiseList());
        }

    }


    /**
     * @param iCommentEntity
     */
    private void initICommentData(ICommentEntity iCommentEntity) {

        LoadImageUtils.getInstance().loadListCircleImage(mUserImg, iCommentEntity.getIHeadPic());

        ImageLoadUtils.loadImage(iCommentEntity.getIHonourPic(), ivHonourPic);
        tvArmyGroupInfo.setText(iCommentEntity.getIArmyGroupInfo());

        mUsername.setText(iCommentEntity.getINickName());
        LoadImageUtils.getInstance().loadImage(mUserRank, iCommentEntity.getIRankIcon());
        mUserRankText.setText(iCommentEntity.getIRankName());
//            mComZan.setText(commentSecondaryBean.getPraiseNum());
        mComMesg.setPicText(iCommentEntity.getIContent());
        mComTime.setText(iCommentEntity.getIPublishTime());
    }


    /**
     * 创建点赞的view
     *
     * @param iLaud      点赞类
     * @param praiseList 点赞头像的list
     */
    private void initPariseView(ILaud iLaud, List<PariseBean> praiseList) {

        this.praiseList = praiseList;
        if (this.praiseList == null) {
            this.praiseList = new ArrayList<PariseBean>();
        }

        mComZan.setText(TextUtils.isEmpty(iLaud.getILaudNum()) || iLaud.getILaudNum().equals("0") ? "" : iLaud.getILaudNum());
        for (int i = 0; i < this.praiseList.size(); i++) {
            if (InteractiveUtils.getInstance().theDefriendIsContains(praiseList.get(i).getUid())) {
                praiseList.remove(praiseList.get(i));
                i--;
            }
        }

        //判断是否点赞过
        if (InteractiveUtils.getInstance().theLaudIsContains(iLaud.getICommentId(), true)) {
            mComZan.setEnabled(false);
            laud.setTag(true);
            if (UserInforManager.getInstance().isLogin()) {
                //如果登录了则把用户头像加入到第一个位置
                UserInfor userInfor = UserInforManager.getInstance().getUserInfor();
                PariseBean pariseBean = new PariseBean();
                pariseBean.setHeadPic(userInfor.getHeadPic());
                pariseBean.setNickName(userInfor.getNickName());
                pariseBean.setUid(userInfor.getUid());
                this.praiseList.add(0, pariseBean);
            }
        } else {
            mComZan.setEnabled(true);
            laud.setTag(iLaud);
        }


        if (this.praiseList.size() <= 0) return;
        pariseLayoutContainer.setVisibility(View.VISIBLE);
        pariseBotLine.setVisibility(View.VISIBLE);
        View.OnClickListener onClickListener = new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (v == null || v.getTag() == null) {
                    return;
                }
                String uid = v.getTag().toString();
                MyHomepageDynamicActivity.goToUserHomePage(ActivityUtils.getTopActivity(), uid);
            }
        };

        if (pariseListView != null) {

            pariseListView.removeAllViews();


            for (int i = 0; i < this.praiseList.size(); i++) {
                if (i < 5) {
                    PariseBean pariseBean = this.praiseList.get(i);
                    if (pariseBean == null) {
                        i--;
                        praiseList.remove(pariseBean);
                        continue;
                    }
                    if (i != 0 && UserInforManager.getInstance().isLogin() &&
                            TextUtils.equals(UserInforManager.getInstance().getUserInfor().getUid(), pariseBean.getUid())) {
                        //如果当前点赞用户和本地登录用户uid一样,则跳过
                        i--;
                        praiseList.remove(pariseBean);
                        continue;
                    }
                    CircleImageOnly circleImageOnly = new CircleImageOnly(this, pariseBean.getHeadPic(), 32, R.color.common_bg_color_9);
                    pariseListView.addView(circleImageOnly);

                    circleImageOnly.setTag(pariseBean.getUid());
                    LinearLayout.LayoutParams layoutParams1 = (LinearLayout.LayoutParams) circleImageOnly.getLayoutParams();
                    layoutParams1.rightMargin = ViewSizeUtils.dp2px(this, 5);
                    circleImageOnly.setLayoutParams(layoutParams1);
                    circleImageOnly.setOnClickListener(onClickListener);


//                    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewSizeUtils.dp2px(context, 32), ViewSizeUtils.dp2px(context, 32));
//                    layoutParams.rightMargin = ViewSizeUtils.dp2px(this, 5);
//                    CircleImageView circleImageView = new CircleImageView(this);
//                    circleImageView.setLayoutParams(layoutParams);
//
//                    LoadImageUtils.getInstance().loadCircleByVolley(this,circleImageView,pariseBean.getHeadPic(),R.drawable.user_head_def,R.drawable.user_head_def);
//                    pariseListView.addView(circleImageView);
//                    circleImageView.setTag(pariseBean.getUid());
//                    circleImageView.setOnClickListener(onClickListener);


                }
            }


        }

        pariseSum = (TextView) findViewById(R.id.comment_zan_sum);
        pariseSum.setText(AppApplication.getInstance().getString(R.string.common_laud_num, iLaud.getILaudNum()));
    }


    /**
     * 点赞的监听器
     */
    private LaudListener laudListener = new LaudListener() {

        @Override
        public void startCommit(ILaud iLaud) {

        }

        @Override
        public void finish(ILaud iLaud) {
            //进行点赞后的操作
            if (UserInforManager.getInstance().isLogin()) {

                if (praiseList != null && praiseList.size() > 0
                        && TextUtils.equals(UserInforManager.getInstance().getUserInfor().getUid(), praiseList.get(0).getUid())) {
                    return;
                }

                if (pariseLayoutContainer.getVisibility() == View.GONE) {
                    pariseLayoutContainer.setVisibility(View.VISIBLE);
                    pariseBotLine.setVisibility(View.VISIBLE);

                }
                UserInfor userInfor = UserInforManager.getInstance().getUserInfor();
                CircleImageOnly circleImageOnly = new CircleImageOnly(SecondaryCommentDetailActivity.this, userInfor.getHeadPic(), 32, R.color.common_bg_color_9);


//                CircleImageView circleImageView = new CircleImageView(SecondaryCommentDetailActivity.this);
//                if (pariseListView.getChildCount() >= 5) {
//                    pariseListView.removeViewAt(pariseListView.getChildCount() - 1);
//                }
//                LoadImageUtils.getInstance().loadCircleByVolley(SecondaryCommentDetailActivity.this,circleImageView,userInfor.getHeadPic(),R.drawable.user_head_def,R.drawable.user_head_def);
//                pariseListView.addView(circleImageView, 0);
//                circleImageView.setTag(userInfor.getUid());
//                LinearLayout.LayoutParams layoutParams1 =  new LinearLayout.LayoutParams(ViewSizeUtils.dp2px(SecondaryCommentDetailActivity.this, 32),ViewSizeUtils.dp2px(SecondaryCommentDetailActivity.this, 32));
//                layoutParams1.rightMargin = ViewSizeUtils.dp2px(SecondaryCommentDetailActivity.this, 5);
//                circleImageView.setLayoutParams(layoutParams1);
//                View.OnClickListener onClickListener = new View.OnClickListener() {
//                    @Override
//                    public void onClick(View v) {
//                        if (v == null || v.getTag() == null) {
//                            return;
//                        }
//                        String uid = v.getTag().toString();
//                        gonToUserHome(uid);
//                    }
//                };
//                circleImageView.setOnClickListener(onClickListener);
//


                pariseListView.addView(circleImageOnly, 0);
                circleImageOnly.setTag(userInfor.getUid());
                LinearLayout.LayoutParams layoutParams1 = (LinearLayout.LayoutParams) circleImageOnly.getLayoutParams();
                layoutParams1.rightMargin = ViewSizeUtils.dp2px(SecondaryCommentDetailActivity.this, 5);
                circleImageOnly.setLayoutParams(layoutParams1);
                View.OnClickListener onClickListener = new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        if (v == null || v.getTag() == null) {
                            return;
                        }
                        String uid = v.getTag().toString();
                        MyHomepageDynamicActivity.goToUserHomePage(ActivityUtils.getTopActivity(), uid);
                    }
                };
                circleImageOnly.setOnClickListener(onClickListener);
            }
            //设置点赞数
            if (pariseSum != null) {
                pariseSum.setText(AppApplication.getInstance().getString(R.string.common_laud_num, iLaud.getILaudNum()));
                lauded = true;
            }


        }
    };

    /**
     * 跳转新闻详情
     */
    private void toNewsDetail() {
        if (commentSecondaryBean == null && postCmtSecondaryHeaderBean == null) {
            return;
        }
        if (commentSecondaryBean == null && postCmtSecondaryHeaderBean != null) {

            NewsEntity newsEntity = new NewsEntity();
            newsEntity.setArticleId(postCmtSecondaryHeaderBean.getNewsId());
            newsEntity.setArticleType(postCmtSecondaryHeaderBean.getArticleType());
            TypeConstant.openTypeDetail(newsEntity, this, "");
        }

        if (commentSecondaryBean != null && postCmtSecondaryHeaderBean == null) {
            NewsEntity newsEntity = new NewsEntity();
            newsEntity.setArticleId(commentSecondaryBean.getNewsId());
            newsEntity.setGameId(commentSecondaryBean.getGameId());
            newsEntity.setArticleType(commentSecondaryBean.getArticleType());
            TypeConstant.openTypeDetail(newsEntity, this, "");
        }


    }


    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

    }


    @Override
    public void onBackPressed() {

        Intent intent = null;
        if (lauded) {
            if (intent == null) {
                intent = new Intent();
            }
            intent.putExtra(Config.Extra.PARAMETER1, lauded);
        }


        setResult(RESULT_OK, intent);
        super.onBackPressed();

    }


    @Override
    public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) {

        super.onPullDownToRefresh(refreshView);

    }
}
